<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\massage\model;

class BtnConfig extends \app\BaseModel
{
    protected $name = "massage_service_btn_config";
    public function dataAdd($data)
    {
        $res = $this->insert($data);
        return $res;
    }
    public function dataUpdate($dis, $data)
    {
        $res = $this->where($dis)->update($data);
        return $res;
    }
    public function dataList($dis, $page)
    {
        $data = $this->where($dis)->order("status desc,id desc")->paginate($page)->toArray();
        return $data;
    }
    public function dataInfo($dis)
    {
        $data = $this->where($dis)->find();
        return !empty($data) ? $data->toArray() : [];
    }
    public function initData($uniacid)
    {
        $config = longbingGetAppConfig($uniacid);
        $arr = [["type" => 1, "text" => "可服务", "btn_color" => $config["service_btn_color"], "font_color" => $config["service_font_color"]], ["type" => 2, "text" => "服务中", "btn_color" => "#2A2D35", "font_color" => "#FFFFFF"], ["type" => 3, "text" => "可预约", "btn_color" => "#FF971E", "font_color" => "#FFFFFF"], ["type" => 4, "text" => "不可预约", "btn_color" => "#E82F21", "font_color" => "#FFFFFF"]];
        $key = "init_bnt_config_key";
        incCache($key, 1, $uniacid, 30);
        if(getCache($key, $uniacid) == 1) {
            foreach ($arr as $ks => $vs) {
                $find = $this->where(["uniacid" => $uniacid, "type" => $vs["type"]])->find();
                if(empty($find)) {
                    $vs["uniacid"] = $uniacid;
                    $this->insert($vs);
                }
            }
        }
        decCache($key, 1, $uniacid);
        return true;
    }
}

?>